package com.github.util;

import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

public class Main5 {
	private static DateFormat format = new SimpleDateFormat("yyyy-MM-dd");

	public static void main(String[] args) throws Throwable {

		File excelFile = new File("E:\\source\\Excel4J\\src\\test\\resource\\test_excel.xlsx");

		List<Person> list = new ArrayList<Person>();
		for (int i = 1; i < 10000; i++) {
			list.add(new Person(i+80000, "范忠云" + i, i % 2 == 0, format.parse("1990-04-0" + i)));
		}

		// 属性与 Excel 列的映射关系
		LinkedHashMap<String, String> mapper = new LinkedHashMap<String, String>();
		mapper.put("id", "编号");
		mapper.put("name", "姓名");
		//mapper.put("local", "本地户口");
		mapper.put("birthday", "出生日期");

		// 创建一个可写的 Excel 对象
		WritableExcel excel = new WritableExcel(list, mapper);

		// 写出 Excel 文档文件
		boolean success = excel.write(excelFile);

		if (success) {
			System.out.println("Excel 生成成功！");
		}
	}
}
